#include"common.h"

using std::cout;
using std::endl;
using std::cerr;

int main()
{
    int pipefd=open(IPC_PATH,O_WRONLY);
    if(pipefd<0)
    {
        cerr<<"open fifo error"<<endl;
        return 1;
    }

    char serbf[1024];
    while(true)
    {
        printf("please input message:");
        fflush(stdout);
        memset(serbf,0,sizeof(serbf));
        if(fgets(serbf,sizeof(serbf),stdin)!=nullptr)
        {
            serbf[strlen(serbf)-1]='\0';
            write(pipefd,serbf,strlen(serbf));
        }
        else{
            break;
        }
    }
    close(pipefd);
    cout<<"client exit!"<<endl;

    return 0;
}
